/**
 * 
 */
package edu.sjtu.seda.btrace;

import static com.sun.btrace.BTraceUtils.name;   
import static com.sun.btrace.BTraceUtils.print;   
import static com.sun.btrace.BTraceUtils.println;   
import static com.sun.btrace.BTraceUtils.probeClass;   
import static com.sun.btrace.BTraceUtils.probeMethod;   
import static com.sun.btrace.BTraceUtils.str;   
import static com.sun.btrace.BTraceUtils.strcat;   
import static com.sun.btrace.BTraceUtils.timeMillis;   
  
import com.sun.btrace.annotations.BTrace;   
import com.sun.btrace.annotations.Kind;   
import com.sun.btrace.annotations.Location;   
import com.sun.btrace.annotations.OnMethod;   
import com.sun.btrace.annotations.TLS;

/**
 * @author john.zhu
 *
 */
@BTrace
public class TimeTrace {
	
	@TLS
	private static long startTime = 0;

	@OnMethod(clazz = "edu.sjtu.seda.stage.StageConfigLoader", method = "getStageConfigList")
	public static void startMethod() {
		startTime = timeMillis();
	}

	@SuppressWarnings("deprecation")
	@OnMethod(clazz = "edu.sjtu.seda.stage.StageConfigLoader", method = "getStageConfigList", location = @Location(Kind.RETURN))
	public static void endMethod() {

		print(strcat(strcat(name(probeClass()), "."), probeMethod()));
		print("   [");
		print(strcat("Time taken : ", str(timeMillis() - startTime)));
		println("]");
	}

}
